package sqlapi


import grails.rest.*
import grails.converters.*

class HRSqlApiController {
    static responseFormats = ['json', 'xml']
    static allowedMethods = [query: "POST"]
    def HRDBSqlApiService

    def index() {

    }

    def query(QueryParamsCommand queryParamsCommand) {
//        def start = System.currentTimeMillis()
        def respMap =[:]
        try {
            respMap = [errorCode:0,message:"success",result:HRDBSqlApiService.query(queryParamsCommand)]
        } catch (ex) {
            respMap = [errorCode:-1,message: ex.getMessage(), cause: ex.getCause().toString()]
        }
//        println "查询耗时${System.currentTimeMillis()-start}mms"
        [respMap: respMap]
    }
}

class QueryParamsCommand {
    String sqlString
    Integer offset
    Integer maxRows
    Map params
}
